<template>
  <el-dialog
    v-model="formVisible"
    title="预约详情"
    :close-on-click-modal="false"
    :close-on-press-escape="false"
    append-to-body
    destroy-on-close
    @open="openDialog"
  >
    <div class="form-basic-container-title">预约信息</div>
    <el-form :model="detailData" label-width="120px">
      <el-form-item label="记录来源：">
        <span>{{ detailData?.sourceName }}</span>
      </el-form-item>
      <el-form-item label="预约入校时间：">
        <span
          >{{ detailData?.apptDate }} {{ detailData?.apptWeek }}
          {{ detailData?.apptStartTime }} {{ detailData?.apptEndTime }}</span
        >
      </el-form-item>
    </el-form>
    <div class="form-basic-container-title">预约人员</div>
    <common-table
      border
      :data="detailData?.apptUserList"
      :columns="tableColumns"
    >
      <template #cardType="{ row: { cardType } }">
        <span>1111</span>
      </template>
    </common-table>
    <template #footer>
      <div class="dialog-footer">
        <el-button @click="onUpdate(false)">关闭</el-button>
        <!--        <el-button type="primary" @click="submit">确定</el-button>-->
      </div>
    </template>
  </el-dialog>
</template>

<script setup lang="ts">
import { computed, ref, watch } from "vue";
// import { getDetailData } from "@/api/appt/approval";
// import { getArrayLabel, getArrayName } from "@/utils/array";
// import { useDictStoreHook } from "@/store/modules/dictionary";
import { detailColumns } from "@/views/permission/page/tableData";
const props = defineProps({
  visible: {
    type: Boolean,
    default: false
  },
  row: {
    type: Object,
    default: () => {}
  }
});
const emit = defineEmits(["update:visible", "refresh"]);
const formVisible = ref(false);
const detailData = ref(null);
// const { doorList, cardTypeList } = useDictStoreHook();

const tableColumns = computed(() => {
  return detailColumns;
});
watch(
  () => formVisible.value,
  val => {
    emit("update:visible", val);
  }
);
watch(
  () => props.visible,
  val => {
    formVisible.value = val;
  }
);
// 打开弹框加载数据
async function openDialog() {
  const id = props.row.id;
  const res = await getDetailData(id);
  if (res.code === 200) {
    detailData.value = res.data;
  }
}
// 提交执行操作
const submit = () => {
  onUpdate(false);
  emit("refresh");
};
// 关闭弹框
const onUpdate = (event: Boolean) => {
  emit("update:visible", event);
};
</script>

<style lang="scss" scoped></style>
